package deployr.core;

import java.io.*;

public class Path {

	private final String path;
	private final String root;

	public Path(String path) {
		this(null, path);
	}

	public Path(String root, String path) {
		this.root = root;
		this.path = path;
	}

	public String getName() {
		String name = path.replaceAll(".*/", "");
		String artifactId = name.replaceAll("-.*", "");
		String version = name.replace(artifactId, "");
		return artifactId.concat(version);
	}

	public String getAbsolutePath() {
		return new Option(root).orElse("").concat(path);
	}

	public File getAbsoluteFile() {
		return new File(getAbsolutePath());
	}
}
